<?php
class CPyramidMemberVisit extends Zend_Db_Table
{
	protected $_name = '';
	protected $_primary = '';
	
	public function __construct()
	{
		$this->_name = R_PRE . 'pyramid_member_visit';
		$this->_primary = 'member_visit_id';
		parent::__construct();
	}
	
	public function add($row)
	{
		return $this->insert($row);
	}
	
	public function getFriendsVisitCount($facebookId)
	{
		$db = $this->getAdapter();
		$where = $db->quoteInto('from_facebook_id = ?', $facebookId);
		
		$sql = 'select count(*) as c from ' . $this->_name . ' where ' . $where;
		$result = $db->fetchAll($sql);

		return $result[0]['c'];
	}
}